﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZLDC.Common.Estate;

namespace ZLDC.Estate.PM
{
    public partial class HousingToDeal : _PageBase
    {
        private int Housingid;
        protected void Page_Load(object sender, EventArgs e)
        {
          
                Housingid = _Request.GetInt("hid", 0);
          
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            string sInfo = "";
            sInfo += "[成交日期:" + tbDealDate.Value;
            if (this.rblCompany.SelectedIndex != -1)
            {
                sInfo += ",成交公司:" + this.rblCompany.SelectedItem.Text;
            }

            if (this.tbPrice.Value.Trim() != "")
            {
                sInfo += ",成交价格:" + this.tbPrice.Value.Trim() + "万";
            }

            sInfo += "]";

            //标记成交
            string outmsg = ZLDC.Topo.BLL.Estate.HousingBLL.TranToDeal(Housingid, tbPrice.Value.Trim(), tbDealDate.Value.Trim(), sInfo);
            //添加跟进记录
            ZLDC.Topo.BLL.Estate.HousingFollowBLL.p_housingFollow_save(0, Housingid, "", _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID), _Utility.GetInfoBySession().m_sDeptName, _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID), _Utility.GetInfoBySession().m_sUserName, "[转成交盘]" + sInfo, 0, "");
            
            // 更新缓存
            if (Housingid > 0)
            {
                _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_JSON + Housingid.ToString());
                _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_INFO + Housingid.ToString());
                _Cache.RemoveLike(CacheConst.CACHE_HOUSING_FOLLOW_JSON + Housingid);
            }

            Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('" + outmsg + "');window.close();</script>");
        }
    }
}
